%%{init: {'themeVariables': { 'fontSize': '12px'}}}%%
graph TD
    classDef path fill:#eee,stroke:#000,color:#000
    classDef plan fill:#fff,stroke-width:1px,color:#000
    classDef itemplan fill:#fff,stroke-width:2px,color:#000
    classDef unbatchedplan fill:#dff,stroke-width:1px,color:#000
    classDef sideeffectplan fill:#fcc,stroke-width:2px,color:#000
    classDef bucket fill:#f6f6f6,color:#000,stroke-width:2px,text-align:left

    subgraph "Buckets for queries/super-simple/unique-forum-message"
    Bucket0("Bucket 0 (root)<br /><br />1: PgSelectInlineApply[36]<br />ᐳ: 8, 9, 15, 44, 10<br />2: PgSelectInlineApply[40]<br />3: PgSelect[7]<br />ᐳ: Access[41]<br />4: PgSelectRows[12]<br />ᐳ: First[11], PgSelectSingle[13]"):::bucket
    Bucket1("Bucket 1 (nullableBoundary)<br />Deps: 13, 41<br /><br />ROOT PgSelectSingleᐸforumsᐳ[13]<br />1: <br />ᐳ: 14, 42, 43, 37<br />2: PgSelectRows[23]<br />ᐳ: First[22], PgSelectSingle[24]"):::bucket
    Bucket2("Bucket 2 (nullableBoundary)<br />Deps: 24, 37<br /><br />ROOT PgSelectSingle{1}ᐸmessagesᐳ[24]<br />1: <br />ᐳ: 25, 38, 39<br />2: PgSelectRows[32]<br />ᐳ: First[31], PgSelectSingle[33]"):::bucket
    Bucket3("Bucket 3 (nullableBoundary)<br />Deps: 33<br /><br />ROOT PgSelectSingle{2}ᐸusersᐳ[33]"):::bucket
    end
    Bucket0 --> Bucket1
    Bucket1 --> Bucket2
    Bucket2 --> Bucket3

    %% plan dependencies
    PgSelect7[["PgSelect[7∈0] ➊<br />ᐸforumsᐳ<br />More deps:<br />- Constantᐸ'ca700000-0000-0000-0000-000000000ca7'ᐳ[44]"]]:::plan
    Object10{{"Object[10∈0] ➊<br />ᐸ{pgSettings,withPgClient}ᐳ"}}:::plan
    Access15{{"Access[15∈0] ➊<br />ᐸ0.idᐳ"}}:::plan
    PgSelectInlineApply40["PgSelectInlineApply[40∈0] ➊"]:::plan
    Object10 & Access15 & PgSelectInlineApply40 --> PgSelect7
    Access8{{"Access[8∈0] ➊<br />ᐸ2.pgSettingsᐳ"}}:::plan
    Access9{{"Access[9∈0] ➊<br />ᐸ2.withPgClientᐳ"}}:::plan
    Access8 & Access9 --> Object10
    __Value2["__Value[2∈0] ➊<br />ᐸcontextᐳ"]:::plan
    __Value2 --> Access8
    __Value2 --> Access9
    First11{{"First[11∈0] ➊"}}:::plan
    PgSelectRows12[["PgSelectRows[12∈0] ➊"]]:::plan
    PgSelectRows12 --> First11
    PgSelect7 --> PgSelectRows12
    PgSelectSingle13{{"PgSelectSingle[13∈0] ➊<br />ᐸforumsᐳ"}}:::plan
    First11 --> PgSelectSingle13
    __Value0["__Value[0∈0] ➊<br />ᐸvariableValuesᐳ"]:::plan
    __Value0 --> Access15
    PgSelectInlineApply36["PgSelectInlineApply[36∈0] ➊"]:::plan
    PgSelectInlineApply36 --> PgSelectInlineApply40
    Access41{{"Access[41∈0] ➊<br />ᐸ7.m.joinDetailsFor18ᐳ"}}:::plan
    PgSelect7 --> Access41
    List42{{"List[42∈1] ➊<br />ᐸ41,13ᐳ"}}:::plan
    Access41 & PgSelectSingle13 --> List42
    PgClassExpression14{{"PgClassExpression[14∈1] ➊<br />ᐸ__forums__.”name”ᐳ"}}:::plan
    PgSelectSingle13 --> PgClassExpression14
    First22{{"First[22∈1] ➊"}}:::plan
    PgSelectRows23[["PgSelectRows[23∈1] ➊"]]:::plan
    PgSelectRows23 --> First22
    Lambda43{{"Lambda[43∈1] ➊<br />ᐸpgInlineViaJoinTransformᐳ"}}:::plan
    Lambda43 --> PgSelectRows23
    PgSelectSingle24{{"PgSelectSingle[24∈1] ➊<br />ᐸmessagesᐳ"}}:::plan
    First22 --> PgSelectSingle24
    Access37{{"Access[37∈1] ➊<br />ᐸ43.m.joinDetailsFor27ᐳ"}}:::plan
    Lambda43 --> Access37
    List42 --> Lambda43
    List38{{"List[38∈2] ➊<br />ᐸ37,24ᐳ"}}:::plan
    Access37 & PgSelectSingle24 --> List38
    PgClassExpression25{{"PgClassExpression[25∈2] ➊<br />ᐸ__messages__.”body”ᐳ"}}:::plan
    PgSelectSingle24 --> PgClassExpression25
    First31{{"First[31∈2] ➊"}}:::plan
    PgSelectRows32[["PgSelectRows[32∈2] ➊"]]:::plan
    PgSelectRows32 --> First31
    Lambda39{{"Lambda[39∈2] ➊<br />ᐸpgInlineViaJoinTransformᐳ"}}:::plan
    Lambda39 --> PgSelectRows32
    PgSelectSingle33{{"PgSelectSingle[33∈2] ➊<br />ᐸusersᐳ"}}:::plan
    First31 --> PgSelectSingle33
    List38 --> Lambda39
    PgClassExpression34{{"PgClassExpression[34∈3] ➊<br />ᐸ__users__.”username”ᐳ"}}:::plan
    PgSelectSingle33 --> PgClassExpression34
    PgClassExpression35{{"PgClassExpression[35∈3] ➊<br />ᐸ__users__....vatar_url”ᐳ"}}:::plan
    PgClassExpression34 o--o PgClassExpression35

    %% define steps
    classDef bucket0 stroke:#696969
    class Bucket0,__Value0,__Value2,PgSelect7,Access8,Access9,Object10,First11,PgSelectRows12,PgSelectSingle13,Access15,PgSelectInlineApply36,PgSelectInlineApply40,Access41 bucket0
    classDef bucket1 stroke:#00bfff
    class Bucket1,PgClassExpression14,First22,PgSelectRows23,PgSelectSingle24,Access37,List42,Lambda43 bucket1
    classDef bucket2 stroke:#7f007f
    class Bucket2,PgClassExpression25,First31,PgSelectRows32,PgSelectSingle33,List38,Lambda39 bucket2
    classDef bucket3 stroke:#ffa500
    class Bucket3,PgClassExpression34,PgClassExpression35 bucket3

